<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .outer{
            border: solid 5px darkgray;
            border-radius: 10px;
            float: left;
        }
        .light{
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: lightgray;
            float: left;
        }
        .red{
            background-color: red;
        }
        .yellow{
            background-color: yellow;
        }
        .green{
            background-color: green;
        }
    </style>
</head>
<body>
<div class="outer">
    <div class="light red"></div>
    <div class="light"></div>
    <div class="light"></div>
</div>
<script>
    setInterval(change,1000)
    function change(){
        var outer = document.getElementsByClassName('outer')[0]
        if(outer.children[0].classList.contains('red')){
            outer.children[0].classList.remove('red')
            outer.children[1].classList.add('yellow')
        }else if(outer.children[1].classList.contains('yellow')){
            outer.children[1].classList.remove('yellow')
            outer.children[2].classList.add('green')
        }else{
            outer.children[2].classList.remove('green')
            outer.children[0].classList.add('red')
        }
    }
</script>
</body>
</html>